<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卖家-修改个人信息</title>
<link href="<?php echo $this->_webroot('/user/css/common.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->_webroot('/user/css/content1.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->_webroot('/user/js/jquery-1.7.1.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->_webroot('/user/js/common.js'); ?>" type="text/javascript"></script>


</head>
<body>
<psp:tags     htmlname='user_topnav1'  iconname='usertopnav1' />
<psp:tags     htmlname='user_topsearch'  iconname='usertopsearch' />

<div class="main">
	<div class="main-left">
    	<div class="title">会员管理中心</div>
        <psp:tags     htmlname='user_menulist'  iconname='usermenulist' />
    </div>
<link href="<?php echo $this->_webroot('/user/css/shoprequest.css'); ?>" rel="stylesheet" type="text/css" />   
    <div class="main-right main_right">
	

	
            <div class="cont">
                <div class="cont_title">店铺商品分类<span class="tr_op"><a href="<?php echo $this->_url('goods/categoryadd');?>">添加商品分类</a></span></div>
              
				<table width="100%" border="0" cellspacing="0">
					<tr class="">
					    <th align="left">分类名称</th>
					    <th width="60"></th>
						<th width="40">排序</th>
						<th width="200">操作</th>
					</tr>
					<?php if(empty($category_list_new)){?>
					<tr class="center"><td colspan="4">您还没有添加分类，现在要添加吗？</td></tr>
					<?php 	} else {
					
function get_sub_category ($category_list,$parent_id) {
	$array = array();
	foreach($category_list as $k=>$v) {
		if($v['parent_id']==$parent_id) {
			$array[$k] = $v;
		}
	}
	return $array;
}					
						$category_0 = get_sub_category($category_list_new,0);
						foreach($category_0 as $v) {?>
					<tr>
						<td><img src="<?php echo $this->_webroot('user/images/menu_minus.gif');?>" style="margin-left:1em" />
						<span><a href="#?<?php echo  $v['id'];?>"><?php echo  $v['shop_cat_name'];?></a></span>
						</td>
						 <td class="center edit" id="unit_id_<?php echo  $v['id'];?>"><span onclick="edit_unit(this,<?php echo  $v['id'];?>)">&nbsp;&nbsp;</span></td>
						<td class="center edit" id="cat_id_<?php echo  $v['id'];?>"><span onclick="edit_sort(this,<?php echo  $v['id'];?>)">&nbsp;<?php echo  $v['sort_order'];?>&nbsp;</span></td>
						<td class="center"><a href="<?php echo $this->_url('goods/categoryadd/'.$v['id']);?>">添加子分类</a> <a href="<?php echo $this->_url('goods/categoryedit/'.$v['id']);?>">修改</a> <a href="javascript:del_cat('<?php echo  $v['id'];?>')">删除</a></td>
					</tr>
					<?php 
							$category_sub = get_sub_category($category_list_new,$v['id']);
							if(!empty($category_sub)){
								foreach($category_sub as $value) {?>
							<tr>
								<td><img src="<?php echo $this->_webroot('user/images/menu_minus.gif');?>" style="margin-left:2em" />
								<span><a href="#?<?php echo  $value['id'];?>"><?php echo  $value['shop_cat_name'];?></a></span>
								</td>
								 <td class="center edit" id="unit_id_<?php echo  $value['id'];?>"><span onclick="edit_unit(this,<?php echo  $value['id'];?>)">&nbsp;&nbsp;</span></td> 
								<td class="center edit" id="cat_id_<?php echo  $value['id'];?>"><span onclick="edit_sort(this,<?php echo  $value['id'];?>)">&nbsp;<?php echo  $value['sort_order'];?>&nbsp;</span></td>
								<td class="center"><a href="<?php echo $this->_url('goods/categoryedit/'.$value['id']);?>">修改</a> <a href="javascript:del_cat('<?php echo  $value['id'];?>')">删除</a></td>
							</tr>
							 <?php }?>
							<?php }?>
						<?php }?>
					<?php }?>
					<tr><td colspan="4">&nbsp;&nbsp;注：带灰色背景的可直接点击修改;</td></tr>
				</table>			  
			  
			  
			  
			  
            </div>
	
	

        

    </div>
    <div class="clear"></div>
</div>

<div class="footer">
    <psp:tags     htmlname='user_footer_helper'  iconname='userfooterhelper' />

</div>
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js');?>"></script>
<script language="JavaScript">
<!--
var sort_value,unit_value;
function edit_sort(span,id) {
	obj = document.getElementById("cat_id_"+id);
	sort_value = span.innerHTML;
	sort_value = sort_value.replace(/&nbsp;/ig,"");
	obj.innerHTML = '<input style="width:35px" type="text" id="input_cat_id_' + id + '" value="' + sort_value + '" onblur="edit_sort_post(this,' + id + ')" maxlength="2"  />';
	document.getElementById("input_cat_id_"+id).focus();
}

function edit_sort_post(input,id) {
	var obj = document.getElementById("cat_id_"+id);
	if(isNaN(input.value)) {
		alert("请输入数字！");
		obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + sort_value + '&nbsp;</span>';
		return ;
	}
	if(sort_value==input.value) {
		obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + sort_value + '&nbsp;</span>';
	} else {
		ajax("do.php?act=shop_catsort_edit","POST","id="+id+"&v="+input.value,function(data){
			if(data==1) {
				obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + input.value + '&nbsp;</span>';
			} else {
				obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + sort_value + '&nbsp;</span>';
			}
		});
	}
}

function edit_unit(span,id){
	obj = document.getElementById("unit_id_"+id);
	unit_value = span.innerHTML;
	unit_value = unit_value.replace(/&nbsp;/ig,"");
	obj.innerHTML = '<input style="width:35px" type="text" id="input_unit_id_' + id + '" value="' + unit_value + '" onblur="edit_unit_post(this,' + id + ')" maxlength="8" />';
	document.getElementById("input_unit_id_"+id).focus();
}

function edit_unit_post(input,id) {
	var obj = document.getElementById("unit_id_"+id);
	if(unit_value==input.value) {
		obj.innerHTML = '<span onclick="edit_unit(this,' + id + ')">&nbsp;' + unit_value + '&nbsp;</span>';
	} else {
		ajax("do.php?act=shop_catunit_edit","POST","id="+id+"&v="+input.value,function(data){
			if(data==1) {
				obj.innerHTML = '<span onclick="edit_unit(this,' + id + ')">&nbsp;' + input.value + '&nbsp;</span>';
			} else {
				obj.innerHTML = '<span onclick="edit_unit(this,' + id + ')">&nbsp;' + unit_value + '&nbsp;</span>';
			}
		});
	}
}

function del_cat(id){
	if(confirm("您确定要删除此分类及其下头的所有子分类吗？")) {
		location.href="<?php echo $this->_url('goods/categorydel/');?>"+id;
	}
}
//-->
</script>

</body>
</html>